package util

import (
	"os"
)

func pathExists(path string) (bool, error) {
	_, err := os.Stat(path)
	if err == nil {
		return true, nil
	}
	if os.IsNotExist(err) {
		return false, nil
	}
	return false, err
}

func CheckFolder() {
	if exist, _ := pathExists("./file/"); !exist {
		_ = os.Mkdir("./file", os.ModePerm)
	}
	var folderNames = [...]string{"avatar", "carousel", "cover", "logs", "video"}
	for _, item := range folderNames {
		if exist, _ := pathExists("./file/" + item); !exist {
			_ = os.Mkdir("./file/"+item, os.ModePerm)
		}
	}
}
